//
//  zhuceViewController.m
//  UI_豆瓣项目
//
//  Created by dllo on 15/11/2.
//  Copyright (c) 2015年 关业达. All rights reserved.
//

#import "zhuceViewController.h"
#import "UserLogin.h"
#import "zhuceView.h"
#import "UserSingleton.h"
#import "LoginViewController.h"
@interface zhuceViewController ()

@end

@implementation zhuceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.zhuce = [[zhuceView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [self.view addSubview:self.zhuce];
    [_zhuce release];
    
    
    self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"注册" style:UIBarButtonItemStylePlain target:self action:@selector(rightAction:)] autorelease];
    
    
}


- (void)rightAction:(UIButton *)btn
{
    [[UserSingleton shareSingleton] openUB];
    [[UserSingleton shareSingleton] createTable];
    
    UserLogin *user = [[UserLogin alloc] init];
    user.uname = self.zhuce.nameTF.text;
//    NSLog(@"=====%@", user.name);
    user.code = self.zhuce.codeTF.text;
//    NSLog(@"=====%@", user.code);
    [[UserSingleton shareSingleton] insertUser:user];
    
    LoginViewController *login = [[LoginViewController alloc] init];
    [self.navigationController pushViewController:login animated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
